package cn.idietrade.idietradegoodsorder8003.demo.controller;

import cn.idietrade.common.utils.ReturnResultData;
import cn.idietrade.idietradegoodsorder8003.demo.service.OrderGoodsService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author zjy
 * @version 1.0
 * @createTime 2022-12-25 14:51
 * @description
 */
@RestController
public class OrderGoodsController {
    @Resource
    private OrderGoodsService orderGoodsService;

    @RequestMapping("/addOrderGoods")
    public ReturnResultData addOrderGoods(Integer orderId,Integer userId,String goodsIds,String nums){
        ReturnResultData resultData =new ReturnResultData<>();
        int i = orderGoodsService.addOrderGoods(orderId, userId, goodsIds, nums);
        if(i>0){
            resultData.setCode(1);
            resultData.setMessage("订单商品中间表数据添加成功");
            resultData.setData(null);
        }else{
            resultData.setCode(0);
            resultData.setMessage("订单商品中间表数据添加失败");
            resultData.setData(null);
        }

        return  resultData;
    }
}
